package com.pulse.base.service.impl;

import com.pulse.base.domain.Alarm;
import com.pulse.base.mapper.AlarmMapper;
import com.pulse.base.service.IAlarmService;
import com.pulse.common.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Collections;
import java.util.List;

@Service
public class AlarmServiceImpl implements IAlarmService {

    @Autowired
    private AlarmMapper alarmMapper;

    /**
     * 新增
     *
     * @param alarm
     * @return
     */
    @Override
    public int insertAlarm(Alarm alarm) {
        return alarmMapper.insertAlarm(alarm);
    }

    /**
     * 根据设备编号删除
     *
     * @param deviceNo
     * @return
     */
    @Override
    public int deleteByDeviveNo(String deviceNo) {
        return alarmMapper.deleteAlarmByDeviceNo(deviceNo);
    }

    /**
     * 查询报警记录
     *
     * @param alarm
     * @return
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<Alarm> selectAlarmList(Alarm alarm) {
        return alarmMapper.selectAlarmList(alarm);
    }
}
